﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;

namespace OpenWaves.Pagination
{
    [ContractClass(typeof(PageContract<>))]
#if !SILVERLIGHT && NET_40_OR_GREATER
    public interface IPage<out T>
#else
    public interface IPage<T>
#endif
    {
        int Index { get; }
        int FirstItemIndex { get; }
        int LastItemIndex { get; }
        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
        IEnumerable<T> GetItemsRange();
    }

    [ContractClassFor(typeof(IPage<>))]
    public abstract class PageContract<T> : IPage<T>
    {
        public int Index
        {
            get
            {
                Contract.Ensures(Contract.Result<int>() >= 0);
                throw new NotImplementedException();
            }
        }

        public int FirstItemIndex
        {
            get 
            { 
                Contract.Ensures(Contract.Result<int>() >=0); 
                throw new NotImplementedException();
            }
        }

        public int LastItemIndex
        {
            get
            {
                Contract.Ensures(Contract.Result<int>() >= 0);
                throw new NotImplementedException();
            }
        }

        public IEnumerable<T> GetItemsRange()
        {
            Contract.Ensures(Contract.Result<IEnumerable<T>>() != null);
            throw new NotImplementedException();
        }
    }
}